from embedding_hyd.embedding_implement import Embedding
import os
import numpy as np
from faiss_database_hyd.faiss_database import FaissDataBase
from qianfan_big_model.qianfan_big_model import QianfanBigModel

api_tokens = "NAjHiybRP3UXzENY0E4XDsfo"
secret_tokens = "W23YOtWRGLHqSSxEsZ1e6Wvwxin1Fy9S"


# a1 = Embedding(api_tokens, secret_tokens)
# # data_list = Embedding().read_csv_col_tolist("./train_data_csv.csv", "instruction")
# # # print(data_list)
# # embedding_data = a1.get_embedding_data(data_list)
# # print(embedding_data)
# # Embedding.save_embedding_data(embedding_data)
#
# # embedding_data = np.load("./embedding_data.npy")
# # print(embedding_data)
# # print(embedding_data.dtype)
#
# # print(os.getcwd())
#
# ed = "./embedding_data.npy"
# kb = "./train_data_csv.csv"
#
# query_data = ["悬空寺的建筑和现代建筑有什么不同？"]
#
# a1 = Embedding(api_tokens, secret_tokens)
# query_embedding = a1.encode_str(query_data)
#
# d = 384
# # print(len(query_embedding[0]))
#
# faiss1 = FaissDataBase(384, ed, kb)
# faiss1_l2 = faiss1.create_index_l2()
# data = faiss1.search_vector_text(faiss1_l2, 2, query_embedding)
# print(data)

big_model = QianfanBigModel(api_tokens, secret_tokens)
message_info = [
            {
                "role": "user",
                "content": "你好"
            },
            {
                "role": "assistant",
                "content": "我是百度公司开发的人工智能语言模型，我的中文名是文心一言，英文名是ERNIE-Bot，可以协助您完成范围广泛的任务并提供有关各种主题的信息，比如回答问题，提供定义和解释及建议。如果您有任何问题，请随时向我提问。"
            },
            {
                "role": "user",
                "content": "我在上海，周末可以去哪里玩？"
            }
        ]
anwser = big_model.brnie_bot_turbo_stream(message_info)

for i in anwser:
    print(i, end="")

